package com.museum.impl;

import com.alibaba.fastjson.JSONObject;
import com.museum.service.SendSms;
import com.museum.base.BaseApiService;
import com.museum.base.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * User: 王瑞文
 * Date: 2020/9/6
 * Time: 11:50
 * To change this template use File | Settings | File Templates.
 * Description:
 */
@SuppressWarnings("all")
@RestController
public class SmsServiceImpl extends BaseApiService<JSONObject> implements SMSService {
    @Autowired
    private SendSms sendSms;

    @Override
    public BaseResponse<JSONObject> sendSms(String phone) {
        boolean flog = sendSms.sendSms(phone);
        if (flog)
            return setResultSuccess("发送成功！");
        else
            return setResultError("发送失败！");
    }

    @Override
    public BaseResponse<JSONObject> checkSms(String phone, String code) {
        boolean flog = sendSms.yanSms(phone, code);
        if (flog) return setResultSuccess("验证成功！");
        else return setResultError("验证失败！");
    }
}
